package myblog.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import myblog.dao.LogDao;
import myblog.entity.LogEntity;
import myblog.service.LogService;
import myblog.vo.LogsVo;

public class LogServiceImpl implements LogService {
	private LogDao dao = null;

	@Override
	public List<LogsVo> list() {
		List<LogsVo> voList = new ArrayList<LogsVo>();

		List<LogEntity> entityList = dao.list();

		for (LogEntity entity : entityList) {

			LogsVo vo = new LogsVo();

			// 对象属性值拷贝 entity => vo
			BeanUtils.copyProperties(entity, vo);

			voList.add(vo);
		}

		return voList;
	}

	@Override
	public void addlog(LogsVo logVo) {
		dao.addlog(logVo);

	}

	@Override
	public void dellog(String log_id) {
		dao.dellog(log_id);

	}

	@Override
	public LogsVo getlog(String log_id) {
		LogsVo logsVo = new LogsVo();

		LogEntity logEntity = dao.getlog(log_id);

		// 对象属性值拷贝 entity => vo
		BeanUtils.copyProperties(logEntity, logsVo);

		return logsVo;
	}

	@Override
	public void editlog(LogsVo log) {
		dao.editlog(log);

	}

	public void setDao(LogDao dao) {
		this.dao = dao;
	}

}
